package com.job.client.common.rabbitmqConfig;
 
import com.job.client.model.rabbitmq.AuditConstant;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
 

@Configuration
/*
* 审核rabbitmq配置
* */
public class RabbitmqAuditConfig {
    @Bean
    public Exchange EXCHANGE_AUDIT(){
        return ExchangeBuilder
                .directExchange(AuditConstant.EXCHANGE_AUDIT) // 直连交换机，根据key匹配
                .durable(true).build();  // 持久化
    }
    @Bean
    public Queue QUEUE_AUDIT_AVATAR(){
        return new Queue(AuditConstant.QUEUE_AUDIT_AVATAR);
    }
    @Bean
    public Binding BINDING_QUEUE_AUDIT_AVATAR(Queue QUEUE_AUDIT_AVATAR,Exchange EXCHANGE_AUDIT){
        return BindingBuilder.bind(QUEUE_AUDIT_AVATAR)
                .to(EXCHANGE_AUDIT)
                .with(AuditConstant.ROUTINGKEY_AVATAR).noargs();
    }
    @Bean
    public Queue QUEUE_AUDIT_POSTS(){
        return new Queue(AuditConstant.QUEUE_AUDIT_POSTS);
    }
    @Bean
    public Binding BINDING_QUEUE_AUDIT_POSTS(Queue QUEUE_AUDIT_POSTS, Exchange EXCHANGE_AUDIT){
        return BindingBuilder.bind(QUEUE_AUDIT_POSTS)
                .to(EXCHANGE_AUDIT)
                .with(AuditConstant.ROUTINGKEY_POSTS).noargs();
    }
    @Bean
    public Queue QUEUE_AUDIT_COMPANY(){
        return new Queue(AuditConstant.QUEUE_AUDIT_COMPANY);
    }
    @Bean
    public Binding BINDING_QUEUE_AUDIT_COMPANY(Queue QUEUE_AUDIT_COMPANY, Exchange EXCHANGE_AUDIT){
        return BindingBuilder.bind(QUEUE_AUDIT_COMPANY)
                .to(EXCHANGE_AUDIT)
                .with(AuditConstant.ROUTINGKEY_COMPANY).noargs();
    }
}